package com.cxm.server.controller;

import com.cxm.server.pojo.Department;
import com.cxm.server.pojo.Employee;
import io.swagger.annotations.Api;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "helloController")
@RestController
public class HelloController {
    @Autowired
    private BCryptPasswordEncoder bCryptPasswordEncoder;
    @Autowired
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("/test")
    public String test(String password){
        return bCryptPasswordEncoder.encode(password);
    }

    @GetMapping("/test2")
    public boolean test2(String password,String brcy){
        return bCryptPasswordEncoder.matches(password,brcy);
    }

    @GetMapping("/employee/basic/hello")
    public void hello2(){
        String queue="mail.welcome";
        System.out.println("queue = " + queue);
        Employee employee = new Employee();
        employee.setName("cxm");
        Department d = new Department();
        d.setName("工程部");
        employee.setDepartment(d);
        rabbitTemplate.convertAndSend(queue,employee);
    }

}
